<?php

namespace App\Admin\Controllers;

use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;
use \App\Models\JxList;

class JxListsController extends AdminController
{
    protected $title = '吉凶列表';
    
    protected function grid()
    {
        $grid = new Grid(new JxList());
	    $grid->disableExport();
	
	    $grid->column('id', 'ID');
	    $grid->column('name', '吉凶名称');
	    $grid->column('is_better', '是否是更好的卦象')->bool();
	   
	    $grid->column('created_at', '创建时间')->display(function () {
		    return $this->created_at->toDatetimeString();
	    });
	
	    $grid->disableRowSelector();

        return $grid;
    }
	
	 protected function detail($id)
    {
        $show = new Show(JxList::findOrFail($id));
        return $show;
    }
	
    protected function form()
    {
        $form = new Form(new JxList());

	    $form->text('name', '吉凶名称')->rules('required');
	    $form->radio('is_better', '是否是更好的卦象')->options(config('site.bool'))->default(false);
	    
        return $form;
    }
}
